import ajax from '@/api/ajax'
import mockAjax from '@/api/mockAjax'

export function reqGetBaseCategoryList() {
  return ajax.get('/product/getBaseCategoryList')
}

export const reqGetBannerListData = () => mockAjax.get('/banner')

export const reqGetFloorsListData = () => mockAjax.get('/floors')

//获取搜索页面搜索结果
export const reqGetGoodsInfoData = (searchParams) =>
  ajax.post('/list', searchParams)
// export const reqGetGoodsInfoData = () => {
//   return ajax({
//     url: '/list',
//     methods: 'post',
//     data: searchParams,
//   })
// }

export const reqGoodDetailInfoData = (id) => ajax.get('/item/' + id)

//获取购物车列表
export const reqGetShopCartListData = () => ajax.get('cart/cartList')

//添加购物车
export const reqAddToCart = (skuId, skuNum) =>
  ajax.post(`/cart/addToCart/${skuId}/${skuNum}`)

//更改单个商品的选中状态
export const reqUpdateSkuCheckState = (skuID, isChecked) =>
  ajax.get(`/cart/checkCart/${skuID}/${isChecked}`)

//批量选中购物车商品
export const reqCheckAllShopCart = (isChecked, skuIdList) =>
  ajax.post(`/cart/batchCheckCart/${isChecked}`, skuIdList)

//删除一个购物车商品
export const reqDelOneShopCart = (skuId) =>
  ajax.delete(`/cart/deleteCart/${skuId}`)

//批量删除购物车
export const reqDelAllCheckedCart = (skuIdList) =>
  ajax.delete(`/cart/batchDeleteCart`, { data: skuIdList })

//注册页面获取验证码的请求
export const reqGetVerifyCode = (phone) =>
  ajax.get(`/user/passport/sendCode/${phone}`)

//发起注册的请求
export const reqUserRegister = (user) =>
  ajax.post('/user/passport/register', user)

//用户发送登录请求
export const reqUserLogin = (user) => ajax.post('/user/passport/login', user)

//用户退出登录请求
export const reqUserLogout = () => ajax.get('/user/passport/logout')

//获取订单交易页数据
export const reqGetTradeInfoData = () => ajax.get('/order/auth/trade')

//提交订单
export const reqSubPay = (tradeNo, params) =>
  ajax.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`, params)

//获取订单支付信息
export const reqGetPaymentInfo = (orderId) =>
  ajax.get(`payment/weixin/createNative/${orderId}`)

//查询支付订单状态
export const reqQueryPayStatus = (orderId) =>
  ajax.get(`payment/weixin/queryPayStatus/${orderId}`)

//获取订单列表
export const reqOrderListData = (page, limit) =>
  ajax.get(`/order/auth/${page}/${limit}`)
